




package mvc.view
{
	import flash.events.Event;
	import mvc.ApplicationFacade;
	import mvc.view.components.CollDisplay;

	
	import org.puremvc.as3.interfaces.INotification;
	import org.puremvc.as3.patterns.mediator.Mediator;

	public class CollDisplayMediator extends Mediator
	{
        public static const NAME:String = 'MainDisplayMediator';

        public function CollDisplayMediator( viewComponent:Object ){super( NAME, viewComponent );}
        override public function onRegister():void
        {
        	collDisplay.addEventListener( CollDisplay.COLL_CREATED,		onCollCreated );
//        	collDisplay.addEventListener( CollDisplay.BLANK_CREATED,	onBlankCreated );

        }
		override public function listNotificationInterests():Array
		{
			return [ApplicationFacade.BLANK_MODE,
					ApplicationFacade.COLL_MODE]

		}
       	override public function handleNotification(note:INotification):void
       	{
       		switch (note.getName())
       		{
				case ApplicationFacade.COLL_MODE:		collDisplay.currentViewSelector = CollDisplay.COLL;		break;
				case ApplicationFacade.BLANK_MODE:		collDisplay.currentViewSelector = CollDisplay.BLANK;	break;
       		}
       	}


//		protected function onBlankCreated( event:Event ):void{checkForMediator( CollDisplay.BLANK,			collDisplay.activeView );}
		protected function onCollCreated( event:Event ):void{checkForMediator( CollDisplay.COLL,			collDisplay.activeView );}
		protected function checkForMediator( childSelector:Number, child:Object ):void
        {
			switch (childSelector)
			{
//				case CollDisplay.BLANK:		if (!facade.hasMediator( CollViewMediator.NAME ) )	facade.registerMediator(new CollViewMediator( child ));break;
//				case MainDisplay.ART:		if (!facade.hasMediator( ArtViewMediator.NAME ) )	facade.registerMediator(new ArtViewMediator( child ));break;
				case CollDisplay.COLL:		if (!facade.hasMediator( CollViewMediator.NAME ) )	facade.registerMediator(new CollViewMediator( child ));break;
			}        
        }
		protected function get collDisplay():CollDisplay{return viewComponent as CollDisplay;}
	}
}